﻿using System;

namespace NodeJS
{
    public abstract class QueryString
    {
        /// <summary>
        /// Serialize an object to a query string. Optionally override the default separator ('&') and assignment ('=') characters.
        /// </summary>
        /// <param name="obj"></param>
        /// <param name="sep"></param>
        /// <param name="eq"></param>
        /// <returns></returns>
        public abstract string Stringify(object obj, char sep = '&', char eq = '=');

        /// <summary>
        /// Deserialize a query string to an object. Optionally override the default separator ('&') and assignment ('=') characters.
        /// </summary>
        /// <param name="str"></param>
        /// <param name="sep"></param>
        /// <param name="eq"></param>
        /// <param name="options">Options object may contain maxKeys property (equal to 1000 by default), it'll be used to limit processed keys. Set it to 0 to remove key count limitation.</param>
        /// <returns></returns>
        public abstract object Parse(string str, char sep = '&', char eq = '=', object options = null);

        /// <summary>
        /// The escape function used by querystring.stringify, provided so that it could be overridden if necessary.
        /// </summary>
        public Func<string, string> Escape;

        /// <summary>
        /// The unescape function used by querystring.parse, provided so that it could be overridden if necessary.
        /// </summary>
        public Func<string, string> Unescape;
    }
}
